import http from '../http'
import type { LoginParams, LoginData, UserData } from '@/api/types'
export * from './menu'
export * from './operation'
export * from './role'

export const prefix = '/easy/auth'

/**
 * @description 用户登录
 * @param data
 * @returns token,userid,username
 */
export const _login = (data: LoginParams) =>
  http.post<DataType<LoginData>>(`${prefix}/login`, data)

/**
 * @description 用户信息
 * @returns {auth: Array<UserAuthItem>; userInfo: UserInfo<number>}
 */
export const _userInfo = () =>
  http.get<DataType<UserData>>(`${prefix}/userInfo`)

/**
 * @description 用户登出
 */
export const _logout = () => http.post(`${prefix}/logout`)

/**
 * @description 修改密码
 * @param data {oldPassword: string; newPassword: string}
 */
export const _changePassword = data =>
  http.post(`${prefix}/changePassword`, data)
